<template>
  <div class="high-container">
    <div class="title">评估报告</div>
    <div class="content-info">
      <div class="list flex items-middle">
        <div class="name">评估总分：</div>
        <div class="count">{{companyInfo.totalScore || '0'}}分</div>
      </div>
      <div class="list tips flex items-middle">{{ companyInfo.message }}</div>
      <div class="list flex items-middle">
        <div class="name">评估总分：</div>
        <div class="lable-info">{{companyInfo.companyName || '--'}}</div>
      </div>
      <div class="list flex items-middle">
        <div class="name">项目名称：</div>
        <div class="lable-info">{{companyInfo.evaluationType || '--'}}</div>
      </div>
    </div>
    <div class="content-info">
      <div class="content-title">
        <p>评估结果</p>
      </div>
      <div class="content-table">
        <table cellspacing="0" cellpadding="0" border="1">
          <tbody>
            <tr>
              <th class="half table-cell text-gray">类别</th>
              <th class="flex-1 table-cell text-gray">得分</th>
            </tr>
            <tr>
              <td class="table-cell">发明专利</td>
              <td
                class="table-cell num"
                rowspan="3"
              >{{companyInfo.intellectualPropertyScore || '0'}}</td>
            </tr>
            <tr>
              <td class="table-cell">实用新型专利</td>
            </tr>
            <tr>
              <td class="table-cell">软件著作权</td>
            </tr>
            <tr>
              <td class="table-cell">成果转化能力</td>
              <td class="table-cell num">{{companyInfo.achievementScore || '0'}}</td>
            </tr>
            <tr>
              <td class="table-cell">研发组织管理水平</td>
              <td class="table-cell num">{{companyInfo.managementLevelScore || '0'}}</td>
            </tr>
            <tr>
              <td class="table-cell" style="width:280px">总资产增长率</td>
              <td class="table-cell num">{{companyInfo.totalAssetsGrowthScore || '0'}}</td>
            </tr>
            <tr>
              <td class="table-cell">销售增长率</td>
              <td class="table-cell num">{{companyInfo.salesGrowthScore || '0'}}</td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
    <div class="content-info">
      <div class="content-title">
        <p>评估说明</p>
      </div>
      <div class="explain">
        认定条件：
        <br />1、在中国境内（不包括港、澳、台地区）注册一年以上的居民企业：
        <br />2、近三年内通过自主研发、受让、受赠、并购等方式，至少获得1项发明专利或5项实用新型专利（含软著）
        <br />3、从事研发和相关技术创新活动的科技人员>10%
        <br />4、中国境内发生的研究开发费用总额（<5千万元，≧5%；5千万元~2亿， ≧ 4%；>2亿元， ≧ 3%）
        <br />5、高新技术产品（服务）收入占企业当年总收/全部 ≧60%
        <br />6、创新能力评价达70分以上
      </div>
    </div>
    <div class="content-info flex flex-center">
      <el-button type="primary" size="medium" @click="onDialog">精准测评</el-button>
    </div>
    <el-dialog title="精准测评" :visible.sync="visible" @close="close">
      <el-form label-width="200px">
        <el-form-item :label="`${thisYear-3}年净资产(万元)：`">
          <el-input v-model="form.lastThreeYearsNetAssets" style="width:250px" placeholder="请输入" />
        </el-form-item>
        <el-form-item :label="`${thisYear-2}年净资产(万元)：`">
          <el-input v-model="form.lastTwoYearsNetAssets" style="width:250px" placeholder="请输入" />
        </el-form-item>
        <el-form-item :label="`${thisYear-1}年净资产(万元)：`">
          <el-input v-model="form.lastYearNetAssets" style="width:250px" placeholder="请输入" />
        </el-form-item>
        <el-form-item :label="`${thisYear-3}年销售额(万元)：`">
          <el-input v-model="form.lastThreeYearsSales" style="width:250px" placeholder="请输入" />
        </el-form-item>
        <el-form-item :label="`${thisYear-2}年销售额(万元)：`">
          <el-input v-model="form.lastTwoYearsSales" style="width:250px" placeholder="请输入" />
        </el-form-item>
        <el-form-item :label="`${thisYear-1}年销售额(万元)：`">
          <el-input v-model="form.lastYearSales" style="width:250px" placeholder="请输入" />
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button type="primary" @click="onSave">提 交</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { getDeclareHigh } from "../../../api/declare.js";
let d = new Date();
let year = d.getFullYear();
export default {
  props: {
    companyName: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      thisYear: year,
      form: {
        lastThreeYearsNetAssets: 0,
        lastTwoYearsNetAssets: 0,
        lastYearNetAssets: 0,
        lastThreeYearsSales: 0,
        lastTwoYearsSales: 0,
        lastYearSales: 0
      },
      companyInfo: {},
      visible: false
    };
  },
  methods: {
    getDetail() {
      getDeclareHigh({ companyName: this.companyName }).then(res => {
        if (res.code === 200) {
          this.companyInfo = res.result;
        } else {
          this.$message({
            type: "warning",
            message: res.message
          });
        }
      });
    },
    onSave() {
      let params = [
        {
          value: this.form.lastThreeYearsNetAssets,
          text: `${this.thisYear - 3}年净资产`
        },
        {
          value: this.form.lastTwoYearsNetAssets,
          text: `${this.thisYear - 2}年净资产`
        },
        {
          value: this.form.lastYearNetAssets,
          text: `${this.thisYear - 1}年净资产`
        },
        {
          value: this.form.lastThreeYearsSales,
          text: `${this.thisYear - 3}年销售额`
        },
        {
          value: this.form.lastTwoYearsSales,
          text: `${this.thisYear - 2}年销售额`
        },
        {
          value: this.form.lastYearSales,
          text: `${this.thisYear - 1}年销售额`
        }
      ];
      for (let i = 0; i < params.length; i++) {
        let obj = params[i];
        let reg = /(^[1-9](\d+)?(\.\d{1,3})?$)|(^\d\.\d{1,3}$)/;
        if (!reg.test(obj.value)) {
          this.$message({
            message: `${obj.text}不能为0,最多三位小数`,
            type: "warning"
          });
          return;
        }
      }
      let form = Object.assign(this.form, { companyName: this.companyName });
      getDeclareHigh(form).then(res => {
        if (res.code === 200) {
          this.companyInfo = res.result;
          this.$message({
            type: "success",
            message: "提交成功"
          });
          setTimeout(() => {
            this.onClose();
          }, 1000);
        } else {
          this.$message({
            type: "warning",
            message: res.message
          });
          this.onClose();
        }
      });
    },
    onDialog() {
      this.visible = true;
    },
    onClose() {
      this.visible = false;
      this.form.lastThreeYearsNetAssets = 0;
      this.form.lastTwoYearsNetAssets = 0;
      this.form.lastYearNetAssets = 0;
      this.form.lastThreeYearsSales = 0;
      this.form.lastTwoYearsSales = 0;
      this.form.lastYearSales = 0;
    }
  }
};
</script>
<style lang="less" scoped src="./index.less"></style>